package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.service.PaymentHystrixService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @USER: dayu Administrator
 * @DATE: 2020/3/26
 * @DESCRIPTION:
 */
@RestController
@Slf4j
public class PaymentHystrixController {
    @Resource
    PaymentHystrixService paymentHystrixService;

    @GetMapping("/payment/get/{id}")
    public String getOk(@PathVariable("id") Long id) {
        return paymentHystrixService.getOk(id);
    }

    @GetMapping("/payment/timeout/{id}")
    public String getTimeout(@PathVariable("id") Long id) {
        return paymentHystrixService.paymentInfoTimeout(id);
    }


    @GetMapping("/payment/circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Long id){
        String result = paymentHystrixService.paymentCircuitBreaker(id);
        log.info("result:"+result);
        return result;

    }
}
